<?php
	if(isset($_GET['pid'])){
		$qty = $_POST['s_quantity'];
		$id = $_GET['pid'];
		$db = new Model_mcart;
		$data = $db->add_cart2($id);
		$_SESSION['cart4'][$id]['name'] = $data['tennguyenlieu'];
		$_SESSION['cart4'][$id]['id'] = $data['manguyenlieu'];
		if(isset($_SESSION['cart4'][$id]['qty'])){
			if(isset($_POST['s_quantity']) && $_POST['s_quantity'] != NULL){
				$_SESSION['cart4'][$id]['qty'] = $_SESSION['cart4'][$id]['qty']+ $qty;
			}else{
				$_SESSION['cart4'][$id]['qty'] = $_SESSION['cart4'][$id]['qty']+1;
			}
		}else{
			if(isset($_POST['s_quantity']) && $_POST['s_quantity'] != NULL){
				$_SESSION['cart4'][$id]['qty'] = $qty;
			}else{
				$_SESSION['cart4'][$id]['qty'] = 1;
			}
		}
		$_SESSION['cart4'][$id]['price'] = $data['dongia'];
		$_SESSION['cart4'][$id]['donvi'] = $data['donvitinh'];
		$_SESSION['cart4'][$id]['nhacungcap'] = $data['tennhacungcap'];
		redirect("index.php?mod=menu&act=import");
	}else{
		die("Vui lòng chọn sản phẩm bạn muốn mua !");
	}
?>